//package com.example.tool.util.sto;
//
//import java.io.BufferedReader;
//import java.io.InputStreamReader;
//import java.io.OutputStream;
//import java.net.HttpURLConnection;
//import java.net.URL;
//import java.nio.charset.StandardCharsets;
//import java.util.Map;
//
//public class StoHttpClient {
//    public static String post(String url, String body, Map<String, String> headers) throws Exception {
//        HttpURLConnection connection = null;
//        try {
//            // 创建连接
//            URL apiUrl = new URL(url);
//            connection = (HttpURLConnection) apiUrl.openConnection();
//            connection.setRequestMethod("POST");
//            connection.setDoOutput(true);
//            connection.setDoInput(true);
//
//            // 设置请求头
//            for (Map.Entry<String, String> entry : headers.entrySet()) {
//                connection.setRequestProperty(entry.getKey(), entry.getValue());
//            }
//
//            // 发送请求体
//            try (OutputStream os = connection.getOutputStream()) {
//                byte[] input = body.getBytes(StandardCharsets.UTF_8);
//                os.write(input, 0, input.length);
//            }
//
//            // 获取响应
//            int responseCode = connection.getResponseCode();
//            if (responseCode == HttpURLConnection.HTTP_OK) {
//                try (BufferedReader br = new BufferedReader(
//                        new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
//                    StringBuilder response = new StringBuilder();
//                    String responseLine;
//                    while ((responseLine = br.readLine()) != null) {
//                        response.append(responseLine.trim());
//                    }
//                    return response.toString();
//                }
//            } else {
//                throw new RuntimeException("HTTP请求失败，状态码: " + responseCode);
//            }
//        } finally {
//            if (connection != null) {
//                connection.disconnect();
//            }
//        }
//    }
//
//}
